package com.wrb.manage.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wrb.manage.response.ServerResponse;
import com.wrb.manage.service.CouponCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wrb
 * @date 2019/12/5 16:47
 */
@RestController
@RequestMapping("/manage/couponCustomer")
@CrossOrigin(origins = "*", methods = {RequestMethod.POST, RequestMethod.GET})
@Api(tags = "用户优惠券管理")
public class CouponCustomerController {

	@Autowired
	private CouponCustomerService couponCustomerService;

	@RequestMapping(value = "/list", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	@ApiOperation(value = "用户优惠券管理列表")
	public ResponseEntity list(
			@ApiParam(required = false, value = "页码") @RequestParam(required = false, defaultValue = "1") Integer pageNo,
			@ApiParam(required = false, value = "每页数量") @RequestParam(required = false, defaultValue = "20") Integer pageSize
	) {
		Page<Object> page = PageHelper.startPage(pageNo, pageSize);
		List list = this.couponCustomerService.getList();
		return ServerResponse.successWithPageHelper(list, page);
	}
}
